#include "camera.h"
#include "../math/functions.h"

// ================================================================================================
// Create the matrix for the camera
// ================================================================================================
void Camera::ConstructMatrix() { 
    Matrix4x4 ident = Identity();
    RotateX(xrot, ident);
    RotateY(yrot, ident);
    Vector4 tempup = up * ident;
    Vector4 tempat = at * ident;
    Vector4 temppos = pos;

    left = CrossProduct(tempup, tempat);

    mat.SetRow1(left);
    mat.SetRow2(tempup);
    mat.SetRow3(tempat);

    transmat = mat.Transpose();

    temppos *= transmat;

    transmat.SetRow4(-temppos);
}

